package com.ruoyi.learn.java.base;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class StringDemo {
    public static void main(String[] args) {
        // String
        String str = "Hello";
        str = str + " World"; // 创建了新对象
        log.info(str);
// StringBuffer
        StringBuffer sb = new StringBuffer("Hello");
        sb.append(" World"); // 在原对象上修改
        log.info(sb.toString());
// StringBuilder
        StringBuilder sbr = new StringBuilder("Hello");
        sbr.append(" World"); // 在原对象上修改
        log.info(sbr.toString());
    }
}
